<?php

include_once 'queryaction.class.php';

class Query extends Queryaction {

    private $debug = null;

    function Query($dbname) {
        parent::Queryaction($dbname);
    }

    public function setDebug($debug) {
        $this->debug = $debug;
        if ($this->debug) {
            $this->renderHeader();
        }
    }

    private function renderHeader() {
        echo '
            <style type="text/css">
            pre {
                background-color: #888888 !important;
                color: #FFFFFF !important;
                font-size: 14px !important;
            }
            </style>
        ';
    }

    function doexecute($sqlres, $sql) {
        $res = array();
        if ($this->debug) {
            echo '<pre>';
            print_r($sql);
            echo '</pre>';
        }
        switch ($sqlres) {
            case "both":
                $res = $this->executeBoth($sql);
                break;
            case "num":
                $res = $this->executeNum($sql);
                break;
            case "assoc":
                $res = $this->executeAssoc($sql);
                break;
            case "debug":
                if (!$this->debug) {
                    $this->renderHeader();
                    echo '<pre>';
                    print_r($sql);
                    echo '</pre>';
                }
                break;
            default:
                $res = $this->executeOnly($sql);
                break;
        }
        return $res;
    }

}

?>
